<?php

use yii\db\Schema;
use yii\db\Migration;

class m160706_064504_add_modify_table extends Migration
{
    public function up()
    {
        $sql = <<<FINE
CREATE TABLE {{%modify}} (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(8) NOT NULL COMMENT '相关的主操作用户 id',
  `user_name` varchar(40) NOT NULL,
  `model` varchar(30) NOT NULL,
  `properties` text NOT NULL COMMENT 'update 的属性(attributes) 集合, json 格式',
  `old_properties` text COMMENT 'update 之前的属性集合, json 格式',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '0 未发送邮件 1已发送邮件',
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
FINE;
        return $this->execute($sql);
    }

    public function down()
    {
        return $this->dropTable('{{%modify}}');
    }


    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
